<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作表单属性</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        #root {
            width: 500px;
            height: 600px;
            background-color: pink;
        }

        h1 {
            font-weight: normal;
            width: 200px;
            height: 50px;
            background-color: green;
            margin: 0 auto;
            text-align: center;
            line-height: 50px;
        }

    </style>
</head>

<body>
    <div id="root">
        <h1>京东登录</h1>
       
            <div><input type="text" placeholder="用户名/手机号/邮箱"></div>
            <div><input type="password" name="password" id="password" /><button id="button">显示密码</button><a href="#">忘记密码</a></div>
        
        <div class="left"><a href="#">短信验证码登录</a></div>
        <div class="right"><a href="#">手机快速注册</a></a></div>
    </div>
</body>
<script>
    let show=false;
   let pass= document.getElementById('password');
   let button=document.getElementById('button');
    button.onclick=function (){
        show=!show
        if(show){
            button.innerText='隐藏密码'
            let val=pass.value
            pass.type='text'
            // pass.value=val
        }else {
            button.innerText='显示密码'
            let val=pass.value
            pass.type='password'
            // pass.value=val
        }
    }
</script>

</html>